//
//  UIDevice+IPhoneModel.m
//  WebViewModifyFontSizeDemo
//
//  Created by Binky Lee on 15/12/22.
//  Copyright © 2015年 Binky Lee. All rights reserved.
//

#import "UIDevice+IPhoneModel.h"

@implementation UIDevice (IPhoneModel)
+(iPhoneModel)iPhoneModel{
    CGRect rect = [[UIScreen mainScreen] bounds];
    
    CGFloat width = rect.size.width;
    CGFloat heigth = rect.size.height;
    
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
    if (UIInterfaceOrientationUnknown == orientation) {
        return Unknown;
    }
    
    //    portrait   width * height
    //    iPhone4:320*480
    //    iPhone5:320*568
    //    iPhone6:375*667
    //    iPhone6Plus:414*736
    
    if (UIInterfaceOrientationPortrait == orientation) {
        if (width == 320.0f) {
            if (heigth == 480.0f) {
                return iPhone4;
            }
            else{
                return iPhone5;
            }
        }
        else if (width == 375.0f){
            return iPhone6;
        }
        else if (width == 414.0f){
            return iPhone6Plus;
        }
    }
    else if (UIInterfaceOrientationLandscapeLeft == orientation ||
             UIInterfaceOrientationLandscapeRight == orientation){
        if (heigth == 320.0f) {
            if (width == 480.0f) {
                return iPhone4;
            }
            else{
                return iPhone5;
            }
        }else if (heigth == 375.0f){
            return iPhone6;
        }
        else if (heigth == 414.0f){
            return iPhone6Plus;
        }
    }
    return Unknown;
}
@end
